//
//  UIBarButtonItem+Extensions.swift
//  weibo 
//
//  Created by 林帆 on 2017/4/5. 
//  Copyright © 2017年 林帆. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /**
      创建 UIBarButtonItem
     
     */
    convenience init(title: String , fontSize: CGFloat = 16, width: CGFloat , target: AnyObject?, action: Selector ) {
        let  btn = UIButton()
        btn.frame = CGRect(x: 0, y: 0, width: width, height: 35)
        btn.titleLabel?.textAlignment = NSTextAlignment.left // 看这里
        btn.setTitle(title, for: .normal)
        
        btn.setTitleColor(#colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1), for: .normal)
        btn.setTitleColor(#colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1), for: .highlighted)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        btn.addTarget(target, action: action, for: .touchUpInside)
     
        // 实例化 UIBarButtonItem
        self.init(customView: btn)
//        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
    }
}
